package com.health.mapp.utils;

import java.util.HashMap;
import java.util.Map;

import com.health.commons.CommonsUtils;

public class LoggerBean {
	
	public final static String KEY_APPID = "appid";
	public final static String KEY_IMSI = "imsi";
	public final static String KEY_IMEI = "imei";
	public final static String KEY_MDN = "mdn";
	public final static String KEY_OPERATOR = "operators";
	public final static String KEY_PROVINCE = "province";
	public final static String KEY_SIM = "sim";
	public final static String KEY_BAND = "band";
	
	public final static String KEY_CHANNEL = "channel";
	public final static String KEY_VERSION = "version";
	public final static String KEY_INFO_TYPE = "infoType";
	public final static String KEY_OS = "os";
	
	private HashMap<String, String> loggerMap = new HashMap<String, String>();
	public LoggerBean() {
	}
	
	public void clean() {
		loggerMap.clear();
	}
	
	public String getBand(){
		String r = loggerMap.get(KEY_BAND);
		if (null == r) {
			r = "";
		}
		return r; 
	}
	
	public String getSim(){
		String r = loggerMap.get(KEY_SIM);
		if (null == r) {
			r = "";
		}
		return r; 
	}
	
	public String getOperator(){
		String r = loggerMap.get(KEY_OPERATOR);
		if (null == r) {
			r = "";
		}
		return r; 
	}
	
	public String getProvince(){
		String r = loggerMap.get(KEY_PROVINCE);
		if (null == r) {
			r = "";
		}
		return r; 
	}
	
	public String getImsi(){
		String r = loggerMap.get(KEY_IMSI);
		if (null == r) {
			r = "";
		}
		return r; 
	}
	
	public String getMdn(){
		String r = loggerMap.get(KEY_MDN);
		if (null == r) {
			r = "";
		}
		return r; 
	}
	
	public String getAppid(){
		String r = loggerMap.get(KEY_APPID);
		if (null == r) {
			r = "";
		}
		return r; 
	}

	public void put(String key, String value) {
		if (CommonsUtils.isEmpty(key) || CommonsUtils.isEmpty(value)) {
			return;
		}
		
		if (loggerMap.containsKey(key)) {
			return;
		}
		
		loggerMap.put(key, value);
	}
	
	public void put(Map<String, String> map) {
		if (null != map && map.size() > 0) {
			loggerMap.putAll(map);
		}
	}
	
	public void putJsonStr(String json) {
		Map<String, Object> map = (Map<String, Object>) CommonsUtils.genBeanByJson(json, Map.class);
		for (String key : map.keySet() ) {
			Object value = map.get(key);
			if (null == value) {
				continue;
			}
			String str = String.valueOf(value);
			if (!CommonsUtils.isEmpty(str)) {
				put(key, str);
			}
		}
	}
	
	public HashMap<String, String> getMap(){
		return loggerMap;
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int a = 4;
		String b = null;
		Object c = b;
			System.out.println(String.valueOf(b));
	}

}
